package main.java.indi.zyj.hot100;

import java.lang.reflect.Array;
import java.util.*;

public class _02_groupAnagrams {
    public List<List<String>> groupAnagrams(String[] strs) {


        HashMap<String, List<String>> hashMap = new HashMap<>();

        for (String str : strs) {
            char[] charArray = str.toCharArray();
            Arrays.sort(charArray);
            String key = new String(charArray);
            List<String> list = hashMap.getOrDefault(key, new ArrayList<>());
            list.add(str);
            hashMap.put(key, list);
        }

        return new ArrayList<List<String>>(hashMap.values());


    }
}
